import React, { useState } from 'react';
import { Button } from 'antd';

const HOC = (Component) => (props) => {
  return (
    <Component
      name={'大家好,我是小杜杜,一起玩转Hooks吧！'}
      {...props}
    ></Component>
  );
};

const Index = (props) => {
  const [flag, setFlag] = useState(false);

  return (
    <div>
      <Button type='primary' onClick={() => setFlag(true)}>
        获取props
      </Button>
      {flag && <div>{JSON.stringify(props)}</div>}
    </div>
  );
};

export default HOC(Index);
